#include<iostream>
#include<algorithm>
using namespace std;

class Solution {
public:
    int strStr(string haystack, string needle) {
        int count = -1;
        int left = 0, right = 0;
        for(int i = 0; i < haystack.size(); i++){
            if(haystack[i] == needle[right]){
                left = i;
                for(int j = 0; j < needle.size(); j++){
                    if(haystack[left++] != needle[j]){
                        count = -1;
                        break;
                    } 
                    else count = i;
                }
                if(count != -1) break;
            }
        }
        return count;
    }
};

int main()
{
    string str1, str2;
    cin >> str1 >> str2;
    cout << Solution().strStr(str1, str2) << endl;
    return 0;
}